home *** CD-ROM | disk | FTP | other *** search
Wrap
Script:LoadScript("scripts/default/entities/pickups/basepickup.lua"); local funcPick=function (self, collider, entering) --printf("collider health is %d < %d > tm< %d >", collider.cnt.health, self.Properties.Amount, self.Properties.RespawnTime); if(collider.cnt.health>=collider.cnt.max_health)then if (entering == 1) then self:NotifyMessage("@medi_pickup_not_possible", collider,2); end return nil; end collider.cnt.health = collider.cnt.health + self.Properties.Amount; if(collider.cnt.health>collider.cnt.max_health)then collider.cnt.health=collider.cnt.max_health; end self:NotifyMessage("@YouPickedUp "..self.Properties.Amount.." @UnitsOf @Health",collider) -- multiplayer statistics local colliderSSID = (Server:GetServerSlotByEntityId(collider.id)):GetId(); if (self.shooterSSID and colliderSSID~=self.shooterSSID) then-- if the health packed was launched by a player, and if this player is not the same that launched the heal MPStatistics:AddStatisticsData(self,"nHealed",1); end return 1; end local params={ func=funcPick, model="Objects/pickups/health/medikit.cgf", default_amount=50, sound="sounds/items/health.wav", modelchoosable=nil, soundchoosable=nil, floating_icon="Objects/Pickups/health/health_icon.cga" } Health=CreateCustomPickup(params); Health._OnInit=Health.Client.OnInit; function Health.Client:OnInit() self:_OnInit(); self:SetViewDistRatio(255); end Health.PhysParam = { mass = 10, size = 0.15, heading = {x=0,y=0,z=-1}, initial_velocity = 6, k_air_resistance = 0, acc_thrust = 0, acc_lift = 0, --high friction material surface_idx = Game:GetMaterialIDByName("mat_pickup"), gravity = {x=0, y=0, z=-9.8 }, collider_to_ignore = nil, constant_orientation=1 } function Health:Launch( weapon, shooter, pos, angles, dir, target ) self.PhysParam.heading = dir; self:SetPhysicParams( PHYSICPARAM_PARTICLE, self.PhysParam ); self:EnableSave(nil); -- fade away after 15 seconds self:SetTimer(15000); pos.x = pos.x + 1.5*dir.x; pos.y = pos.y + 1.5*dir.y; pos.z = pos.z + 1.5*dir.z; self:SetPos( pos ); self:SetAngles( angles ); self:NetPresent(1); -- the ID of the server slot who initiated the action -- used for statistics local serverSlot = Server:GetServerSlotByEntityId(shooter.id); if (serverSlot) then self.shooterSSID = serverSlot:GetId(); end end